#include "include.h"

#define LPK_DI	0x29
#define SPK_DI	0x15

u8	dcsrst[] = {0x05,0x01,0x00};
//*************************************
// Sleep-Out
//*************************************
u8	Sleep_Out[] = {0x05,0x11,0x00};
u8	Sleep_IN[] = {0x05,0x10,0x00};
//DELAY	120
// Display-On
//*************************************
u8	Display_On[] = {0x05,0x29,0x00};

#define CMDNUM  (7)

#if 0		  
//*********************HX8394C  BOE8.0 800X1280 LCD INIT STAR*************************//
//************************************************************//
// Set EXTC
// Set EXTC
u8	dcs0[] = {0x29,0xB9,0xFF,0x83,0x94};
// Set Power
u8	dcs1[] = {0x29,0xB1,0x64,0x10,0x30,0x43,0x34,0x11,0xF1,0x81,0x70,0xD9,0x34,0x80,0xC0,0xD2,0x41};
// Set Display
u8	dcs2[] = {0x29,0xB2,0x45,0x64,0x0F,0x09,0x40,0x1C,0x08,0x08,0x1C,0x4D,0x00,0x00};
// Set CYC
u8	dcs3[] = {0x29,0xB4,0x07,0x6E,0x07,0x71,0x6F,0x70,0x00,0x00,0x01,0x6E,0x0F,0x6E,0x07,0x71,0x6F,0x70,0x00,0x00,0x01,0x6E,0x0F,0x6E};
// Set VCOM
u8	dcs4[] = {0x29,0xB6,0x6F,0x6F,};
// Set PANEL
u8	dcs5[] = {0x15,0xCC,0x09,};

// Set GIP_0
u8	dcs6[] = {0x29,0xD3,0x00,0x08,0x00,0x01,0x07,0x00,0x08,0x32,0x10,0x0A,0x00,0x05,0x00,0x20,0x0A,0x05,0x09,0x00,0x32,0x10,0x08,0x00,0x35,0x33,0x0D,0x07,0x47,0x0D,0x07,0x47,0x0F,0x08,};
// Set GIP_1
u8	dcs7[] = {0x29,0xD5,0x03,0x02,0x03,0x02,0x01,0x00,0x01,0x00,0x07,0x06,0x07,0x06,0x05,0x04,0x05,0x04,0x21,0x20,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x23,0x22,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,};
// Set GAMMA
u8	dcs8[] = {0x29,0xE0,0x03,0x17,0x1C,0x2D,0x30,0x3B,0x27,0x40,0x08,0x0B,0x0D,0x18,0x0F,0x12,0x15,0x13,0x14,0x07,0x12,0x14,0x17,0x03,0x17,0x1C,0x2D,0x30,0x3B,0x27,0x40,0x08,0x0B,0x0D,0x18,0x0F,0x12,0x15,0x13,0x14,0x07,0x12,0x14,0x17,};
// Sleep Out
u8	dcs9[] = {0x05,0x11,0x00,};
//delay_ms(250,
// Set BC Control
u8	dcs10[] = {0x29,0xC9,0x1F,0x2E,0x1E,0x1E,0x10,};
// Display On
u8	dcs11[] = {0x05,0x29,0x00,};
//delay_ms(10,	
#endif 

#if 0
u8	dcs0[] = {0x39,0xB9,0xFF,0x83,0x94};
// Set Power
//            1    2    3    4    5    6    7    8    9    10   11   12   13   14   15   16             
//u8 dcs1[] ={0x39,0xB1,0x64,0x10,0x30,0x43,0x34,0x11,0xF1,0x81,0x70,0xD9,0x34,0x80,0xC0,0xD2,0x41};
u8	dcs1[] = {0x39,0xB1,0x64,0x10,0x30,0x43,0x34,0x11,0xF1,0x81,0x70,0xD9,0x34,0x80,0xC0,0xD2,0x41};
// Set Display
u8	dcs2[] = {0x39,0xB2,0x45,0x64,0x0F,0x09,0x40,0x1C,0x08,0x08,0x1C,0x4D,0x00,0x00};
// Set CYC
u8	dcs3[] = {0x39,0xB4,0x07,0x6E,0x07,0x71,0x6F,0x70,0x00,0x00,0x01,0x6E,0x0F,0x6E,0x07,0x71,0x6F,0x70,0x00,0x00,0x01,0x6E,0x0F,0x6E};
// Set VCOM
u8	dcs4[] = {0x39,0xB6,0x6F,0x6F,};
// Set PANEL
u8	dcs5[] = {0x15,0xCC,0x09,}; // 09
//u8	dcs5[] = {0x39,0xCC,0x09,}; // 09

// Set GIP_0
u8	dcs6[] = {0x39,0xD3,0x00,0x08,0x00,0x01,0x07,0x00,0x08,0x32,0x10,0x0A,0x00,0x05,0x00,0x20,0x0A,0x05,0x09,0x00,0x32,0x10,0x08,0x00,0x35,0x33,0x0D,0x07,0x47,0x0D,0x07,0x47,0x0F,0x08,};
// Set GIP_1
u8	dcs7[] = {0x39,0xD5,0x03,0x02,0x03,0x02,0x01,0x00,0x01,0x00,0x07,0x06,0x07,0x06,0x05,0x04,0x05,0x04,0x21,0x20,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x23,0x22,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,};
// Set GAMMA
u8	dcs8[] = {0x39,0xE0,0x03,0x17,0x1C,0x2D,0x30,0x3B,0x27,0x40,0x08,0x0B,0x0D,0x18,0x0F,0x12,0x15,0x13,0x14,0x07,0x12,0x14,0x17,0x03,0x17,0x1C,0x2D,0x30,0x3B,0x27,0x40,0x08,0x0B,0x0D,0x18,0x0F,0x12,0x15,0x13,0x14,0x07,0x12,0x14,0x17,};
// Sleep Out
u8	dcs9[] = {0x05,0x11,0x00,};
//delay_ms(250,
// Set BC Control
u8	dcs10[] = {0x39,0xC9,0x1F,0x2E,0x1E,0x1E,0x10,};
// Display On
u8	dcs11[] = {0x05,0x29,0x00,};
//delay_ms(10,	
//u8	dcs12[] = {0x39,0xb0, 0x80, 0x01, 0x02, 0x0c};
#endif 


#if 1

u8 kv1  [] = {0x29, 0xFF, 0x98, 0x81, 0x03};
u8 kv2  [] = {0x29, 0x01, 0x00};
u8 kv3  [] = {0x29, 0x02, 0x00};
u8 kv4  [] = {0x29, 0x03, 0x73};
u8 kv5  [] = {0x29, 0x04, 0x06};
u8 kv6  [] = {0x29, 0x05, 0x00};
u8 kv7  [] = {0x29, 0x06, 0x08};
u8 kv8  [] = {0x29, 0x07, 0x06};
u8 kv9  [] = {0x29, 0x08, 0x00};
u8 kv10  [] = {0x29, 0x09, 0x00};
u8 kv11  [] = {0x29, 0x0a, 0x00};
u8 kv12  [] = {0x29, 0x0b, 0x00};
u8 kv13  [] = {0x29, 0x0c, 0x00};
u8 kv14  [] = {0x29, 0x0d, 0x00};
u8 kv15  [] = {0x29, 0x0e, 0x00};
u8 kv16  [] = {0x29, 0x0f, 0x3F};
u8 kv17  [] = {0x29, 0x10, 0x3F};
u8 kv18  [] = {0x29, 0x11, 0x00};
u8 kv19  [] = {0x29, 0x12, 0x00};
u8 kv20  [] = {0x29, 0x13, 0x00};
u8 kv21  [] = {0x29, 0x14, 0x00};
u8 kv22  [] = {0x29, 0x15, 0x00};
u8 kv23  [] = {0x29, 0x16, 0x00};
u8 kv24  [] = {0x29, 0x17, 0x00};
u8 kv25  [] = {0x29, 0x18, 0x00};
u8 kv26  [] = {0x29, 0x19, 0x00};
u8 kv27  [] = {0x29, 0x1a, 0x00};
u8 kv28  [] = {0x29, 0x1b, 0x00};
u8 kv29  [] = {0x29, 0x1c, 0x00};
u8 kv30  [] = {0x29, 0x1d, 0x00};
u8 kv31  [] = {0x29, 0x1e, 0x40};
u8 kv32  [] = {0x29, 0x1f, 0x80};
u8 kv33  [] = {0x29, 0x20, 0x06};
u8 kv34  [] = {0x29, 0x21, 0x01};
u8 kv35  [] = {0x29, 0x22, 0x00};
u8 kv36  [] = {0x29, 0x23, 0x00};
u8 kv37  [] = {0x29, 0x24, 0x00};
u8 kv38  [] = {0x29, 0x25, 0x00};
u8 kv39  [] = {0x29, 0x26, 0x00};
u8 kv40  [] = {0x29, 0x27, 0x00};
u8 kv41  [] = {0x29, 0x28, 0x33};
u8 kv42  [] = {0x29, 0x29, 0x33};
u8 kv43  [] = {0x29, 0x2a, 0x00};
u8 kv44  [] = {0x29, 0x2b, 0x00};
u8 kv45  [] = {0x29, 0x2c, 0x00};
u8 kv46  [] = {0x29, 0x2d, 0x00};
u8 kv47  [] = {0x29, 0x2e, 0x00};
u8 kv48  [] = {0x29, 0x2f, 0x00};
u8 kv49  [] = {0x29, 0x30, 0x00};
u8 kv50  [] = {0x29, 0x31, 0x00};
u8 kv51  [] = {0x29, 0x32, 0x00};
u8 kv52  [] = {0x29, 0x33, 0x00};
u8 kv53  [] = {0x29, 0x34, 0x00};
u8 kv54  [] = {0x29, 0x35, 0x00};
u8 kv55  [] = {0x29, 0x36, 0x00};
u8 kv56  [] = {0x29, 0x37, 0x00};
u8 kv57  [] = {0x29, 0x38, 0x00};
u8 kv58  [] = {0x29, 0x39, 0x00};
u8 kv59  [] = {0x29, 0x3a, 0x00};
u8 kv60  [] = {0x29, 0x3b, 0x00};
u8 kv61  [] = {0x29, 0x3c, 0x00};
u8 kv62  [] = {0x29, 0x3d, 0x00};
u8 kv63  [] = {0x29, 0x3e, 0x00};
u8 kv64  [] = {0x29, 0x3f, 0x00};
u8 kv65  [] = {0x29, 0x40, 0x00};
u8 kv66  [] = {0x29, 0x41, 0x00};
u8 kv67  [] = {0x29, 0x42, 0x00};
u8 kv68  [] = {0x29, 0x43, 0x00};
u8 kv69  [] = {0x29, 0x44, 0x00};
u8 kv70  [] = {0x29, 0x50, 0x01};
u8 kv71  [] = {0x29, 0x51, 0x23};
u8 kv72  [] = {0x29, 0x52, 0x44};
u8 kv73  [] = {0x29, 0x53, 0x67};
u8 kv74  [] = {0x29, 0x54, 0x89};
u8 kv75  [] = {0x29, 0x55, 0xab};
u8 kv76  [] = {0x29, 0x56, 0x01};
u8 kv77  [] = {0x29, 0x57, 0x23};
u8 kv78  [] = {0x29, 0x58, 0x45};
u8 kv79  [] = {0x29, 0x59, 0x67};
u8 kv80  [] = {0x29, 0x5a, 0x89};
u8 kv81  [] = {0x29, 0x5b, 0xab};
u8 kv82  [] = {0x29, 0x5c, 0xcd};
u8 kv83  [] = {0x29, 0x5d, 0xef};
u8 kv84  [] = {0x29, 0x5e, 0x00};
u8 kv85  [] = {0x29, 0x5f, 0x0C};
u8 kv86  [] = {0x29, 0x60, 0x0C};
u8 kv87  [] = {0x29, 0x61, 0x0F};
u8 kv88  [] = {0x29, 0x62, 0x0F};
u8 kv89  [] = {0x29, 0x63, 0x0E};
u8 kv90  [] = {0x29, 0x64, 0x0E};
u8 kv91  [] = {0x29, 0x65, 0x06};
u8 kv92  [] = {0x29, 0x66, 0x07};
u8 kv93  [] = {0x29, 0x67, 0x0D};
u8 kv94  [] = {0x29, 0x68, 0x02};
u8 kv95  [] = {0x29, 0x69, 0x02};
u8 kv96  [] = {0x29, 0x6a, 0x02};
u8 kv97  [] = {0x29, 0x6b, 0x02};
u8 kv98  [] = {0x29, 0x6c, 0x02};
u8 kv99  [] = {0x29, 0x6d, 0x02};
u8 kv100  [] = {0x29, 0x6e, 0x0D};
u8 kv101  [] = {0x29, 0x6f, 0x02};
u8 kv102  [] = {0x29, 0x70, 0x02};
u8 kv103  [] = {0x29, 0x71, 0x05};
u8 kv104  [] = {0x29, 0x72, 0x01};
u8 kv105  [] = {0x29, 0x73, 0x08};
u8 kv106  [] = {0x29, 0x74, 0x00};
u8 kv107  [] = {0x29, 0x75, 0x0C};
u8 kv108  [] = {0x29, 0x76, 0x0C};
u8 kv109  [] = {0x29, 0x77, 0x0F};
u8 kv110  [] = {0x29, 0x78, 0x0F};
u8 kv111  [] = {0x29, 0x79, 0x0E};
u8 kv112  [] = {0x29, 0x7a, 0x0E};
u8 kv113  [] = {0x29, 0x7b, 0x06};
u8 kv114  [] = {0x29, 0x7c, 0x07};
u8 kv115  [] = {0x29, 0x7d, 0x0D};
u8 kv116  [] = {0x29, 0x7e, 0x02};
u8 kv117  [] = {0x29, 0x7f, 0x02};
u8 kv118  [] = {0x29, 0x80, 0x02};
u8 kv119  [] = {0x29, 0x81, 0x02};
u8 kv120  [] = {0x29, 0x82, 0x02};
u8 kv121  [] = {0x29, 0x83, 0x02};
u8 kv122  [] = {0x29, 0x84, 0x0D};
u8 kv123  [] = {0x29, 0x85, 0x02};
u8 kv124  [] = {0x29, 0x86, 0x02};
u8 kv125  [] = {0x29, 0x87, 0x05};
u8 kv126  [] = {0x29, 0x88, 0x01};
u8 kv127  [] = {0x29, 0x89, 0x08};
u8 kv128  [] = {0x29, 0x8A, 0x00};
u8 kv129  [] = {0x29, 0xFF, 0x98, 0x81, 0x04};
u8 kv130  [] = {0x29, 0x6E, 0x3B};
u8 kv131  [] = {0x29, 0x6F, 0x57};
u8 kv132  [] = {0x29, 0x3A, 0xA4};
u8 kv133  [] = {0x29, 0x8D, 0x1F};
u8 kv134  [] = {0x29, 0x87, 0xBA};
u8 kv135  [] = {0x29, 0xB2, 0xD1};
u8 kv136  [] = {0x29, 0x88, 0x0B};
u8 kv137  [] = {0x29, 0x38, 0x01};
u8 kv138  [] = {0x29, 0x39, 0x00};
u8 kv139  [] = {0x29, 0xB5, 0x07};
u8 kv140  [] = {0x29, 0x31, 0x75};
u8 kv141  [] = {0x29, 0x3B, 0x98};
u8 kv142  [] = {0x29, 0xFF, 0x98, 0x81, 0x01};
u8 kv143  [] = {0x29, 0x22, 0x0A};
u8 kv144  [] = {0x29, 0x31, 0x09};
u8 kv145  [] = {0x29, 0x53, 0x62};
u8 kv146  [] = {0x29, 0x55, 0x40};
u8 kv147  [] = {0x29, 0x50, 0x86};
u8 kv148  [] = {0x29, 0x51, 0x82};
u8 kv149  [] = {0x29, 0x60, 0x27};
u8 kv150  [] = {0x29, 0x62, 0x20};
u8 kv151  [] = {0x29, 0xA0, 0x00};
u8 kv152  [] = {0x29, 0xA1, 0x11};
u8 kv153  [] = {0x29, 0xA2, 0x1F};
u8 kv154  [] = {0x29, 0xA3, 0x13};
u8 kv155  [] = {0x29, 0xA4, 0x14};
u8 kv156  [] = {0x29, 0xA5, 0x28};
u8 kv157  [] = {0x29, 0xA6, 0x1D};
u8 kv158  [] = {0x29, 0xA7, 0x1F};
u8 kv159  [] = {0x29, 0xA8, 0x7A};
u8 kv160  [] = {0x29, 0xA9, 0x1C};
u8 kv161  [] = {0x29, 0xAA, 0x2A};
u8 kv162  [] = {0x29, 0xAB, 0x69};
u8 kv163  [] = {0x29, 0xAC, 0x1A};
u8 kv164  [] = {0x29, 0xAD, 0x18};
u8 kv165  [] = {0x29, 0xAE, 0x4D};
u8 kv166  [] = {0x29, 0xAF, 0x22};
u8 kv167  [] = {0x29, 0xB0, 0x29};
u8 kv168  [] = {0x29, 0xB1, 0x4C};
u8 kv169  [] = {0x29, 0xB2, 0x5B};
u8 kv170  [] = {0x29, 0xB3, 0x23};
u8 kv171  [] = {0x29, 0xC0, 0x00};
u8 kv172  [] = {0x29, 0xC1, 0x12};
u8 kv173  [] = {0x29, 0xC2, 0x1F};
u8 kv174  [] = {0x29, 0xC3, 0x12};
u8 kv175  [] = {0x29, 0xC4, 0x15};
u8 kv176  [] = {0x29, 0xC5, 0x29};
u8 kv177  [] = {0x29, 0xC6, 0x1D};
u8 kv178  [] = {0x29, 0xC7, 0x1E};
u8 kv179  [] = {0x29, 0xC8, 0x78};
u8 kv180  [] = {0x29, 0xC9, 0x1D};
u8 kv181  [] = {0x29, 0xCA, 0x29};
u8 kv182  [] = {0x29, 0xCB, 0x69};
u8 kv183  [] = {0x29, 0xCC, 0x19};
u8 kv184  [] = {0x29, 0xCD, 0x18};
u8 kv185  [] = {0x29, 0xCE, 0x4C};
u8 kv186  [] = {0x29, 0xCF, 0x21};
u8 kv187  [] = {0x29, 0xD0, 0x29};
u8 kv188  [] = {0x29, 0xD1, 0x4C};
u8 kv189  [] = {0x29, 0xD2, 0x5B};
u8 kv190  [] = {0x29, 0xD3, 0x23};
u8 kv191  [] = {0x29, 0xFF, 0x98,  0x81,  0x00};
u8 kv192  [] = {0x29, 0x11, 0x00};
u8 kv193  [] = {0x05, 0x11, 0x00};

u8 kv194  [] = {0x29, 0x29, 0x00};
u8 kv195  [] = {0x05, 0x29, 0x00};
u8 kv196  [] = {0x29, 0x35, 0x00};

#endif 

void DcsPktWrite(u8 DCS_DI, u8 Len, u8* Ptr )
{
	u8 i=0;
	HDMI_WriteI2C_Byte( 0xff, 0xd4 );
	if( Len == 2 )
	{  	
		HDMI_WriteI2C_Byte( 0x01, 0x0c );
		HDMI_WriteI2C_Byte( 0x02, 0x04 );
		HDMI_WriteI2C_Byte( 0x03, DCS_DI );
		HDMI_WriteI2C_Byte( 0x03, *Ptr );
		HDMI_WriteI2C_Byte( 0x03, *( Ptr + 1 ) );
	}
	else
	{
		HDMI_WriteI2C_Byte( 0x01, 0x0E );
		HDMI_WriteI2C_Byte( 0x02, Len + 6 );
		HDMI_WriteI2C_Byte( 0x03, DCS_DI );
		HDMI_WriteI2C_Byte( 0x03, Len );
		HDMI_WriteI2C_Byte( 0x03, 0x00 );
		
		for( i = 0; i < Len; i++ )
		{
			HDMI_WriteI2C_Byte( 0x03, *Ptr );
			Ptr++;														   
		}
	}
	HAL_Delay(1);
	HDMI_WriteI2C_Byte( 0x01, 0x00 );
}


void LCD_Reset(void)
{
   
   /*//P10 = 0;
   HAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, GPIO_PIN_RESET);
   HAL_Delay(200);
   //P10 = 1;
   HAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, GPIO_PIN_RESET);
   HAL_Delay(200);*/
}

void InitPanel( void )
{
	//u8 dcslen=0,i=0;
	
	HDMI_WriteI2C_Byte(0xff,0x81);
	HDMI_WriteI2C_Byte(0x0e,0xef);
	HDMI_WriteI2C_Byte(0x0e,0xff);
	HDMI_WriteI2C_Byte(0x0b,0xfe);

	HDMI_WriteI2C_Byte(0xff,0x86);
	HDMI_WriteI2C_Byte(0x47,0x01);
	HDMI_WriteI2C_Byte(0x48,0x01);

	HDMI_WriteI2C_Byte(0xff,0xd4);
	HDMI_WriteI2C_Byte(0x20,0x2f);
	HDMI_WriteI2C_Byte(0x21,0x10);
	
	LCD_Reset();
	printf("\r\nStart initial panel");
	
	/*DcsPktWrite( dcs0[0], ( sizeof( dcs0 ) - 1 ), &dcs0[1] );
	DcsPktWrite( dcs1[0], ( sizeof( dcs1 ) - 1 ), &dcs1[1] );
	DcsPktWrite( dcs2[0], ( sizeof( dcs2 ) - 1 ), &dcs2[1] );
	DcsPktWrite( dcs3[0], ( sizeof( dcs3 ) - 1 ), &dcs3[1] );
	DcsPktWrite( dcs4[0], ( sizeof( dcs4 ) - 1 ), &dcs4[1] );
	DcsPktWrite( dcs5[0], ( sizeof( dcs5 ) - 1 ), &dcs5[1] );
	DcsPktWrite( dcs6[0], ( sizeof( dcs6 ) - 1 ), &dcs6[1] );
	DcsPktWrite( dcs7[0], ( sizeof( dcs7 ) - 1 ), &dcs7[1] );
	DcsPktWrite( dcs8[0], ( sizeof( dcs8 ) - 1 ), &dcs8[1] );
	DcsPktWrite( dcs9[0], ( sizeof( dcs9 ) - 1 ), &dcs9[1] );
	HAL_Delay(300);
	DcsPktWrite( dcs10[0], ( sizeof( dcs10 ) - 1 ), &dcs10[1] );
	DcsPktWrite( dcs11[0], ( sizeof( dcs11 ) - 1 ), &dcs11[1] );
	HAL_Delay(10);*/

	DcsPktWrite( kv1[0], ( sizeof( kv1 ) - 1 ), &kv1[1] );
	DcsPktWrite( kv2[0], ( sizeof( kv2 ) - 1 ), &kv2[1] );
	DcsPktWrite( kv3[0], ( sizeof( kv3 ) - 1 ), &kv3[1] );
	DcsPktWrite( kv4[0], ( sizeof( kv4 ) - 1 ), &kv4[1] );
	DcsPktWrite( kv5[0], ( sizeof( kv5 ) - 1 ), &kv5[1] );
	DcsPktWrite( kv6[0], ( sizeof( kv6 ) - 1 ), &kv6[1] );
	DcsPktWrite( kv7[0], ( sizeof( kv7 ) - 1 ), &kv7[1] );
	DcsPktWrite( kv8[0], ( sizeof( kv8 ) - 1 ), &kv8[1] );
	DcsPktWrite( kv9[0], ( sizeof( kv9 ) - 1 ), &kv9[1] );
	DcsPktWrite( kv10[0], ( sizeof( kv10 ) - 1 ), &kv10[1] );
	DcsPktWrite( kv11[0], ( sizeof( kv11 ) - 1 ), &kv11[1] );
	DcsPktWrite( kv12[0], ( sizeof( kv12 ) - 1 ), &kv12[1] );
	DcsPktWrite( kv13[0], ( sizeof( kv13 ) - 1 ), &kv13[1] );
	DcsPktWrite( kv14[0], ( sizeof( kv14 ) - 1 ), &kv14[1] );
	DcsPktWrite( kv15[0], ( sizeof( kv15 ) - 1 ), &kv15[1] );
	DcsPktWrite( kv16[0], ( sizeof( kv16 ) - 1 ), &kv16[1] );
	DcsPktWrite( kv17[0], ( sizeof( kv17 ) - 1 ), &kv17[1] );
	DcsPktWrite( kv18[0], ( sizeof( kv18 ) - 1 ), &kv18[1] );
	DcsPktWrite( kv19[0], ( sizeof( kv19 ) - 1 ), &kv19[1] );
	DcsPktWrite( kv20[0], ( sizeof( kv20 ) - 1 ), &kv20[1] );
	DcsPktWrite( kv21[0], ( sizeof( kv21 ) - 1 ), &kv21[1] );
	DcsPktWrite( kv22[0], ( sizeof( kv22 ) - 1 ), &kv22[1] );
	DcsPktWrite( kv23[0], ( sizeof( kv23 ) - 1 ), &kv23[1] );
	DcsPktWrite( kv24[0], ( sizeof( kv24 ) - 1 ), &kv24[1] );
	DcsPktWrite( kv25[0], ( sizeof( kv25 ) - 1 ), &kv25[1] );
	DcsPktWrite( kv26[0], ( sizeof( kv26 ) - 1 ), &kv26[1] );
	DcsPktWrite( kv27[0], ( sizeof( kv27 ) - 1 ), &kv27[1] );
	DcsPktWrite( kv28[0], ( sizeof( kv28 ) - 1 ), &kv28[1] );
	DcsPktWrite( kv29[0], ( sizeof( kv29 ) - 1 ), &kv29[1] );
	DcsPktWrite( kv30[0], ( sizeof( kv30 ) - 1 ), &kv30[1] );
	DcsPktWrite( kv31[0], ( sizeof( kv31 ) - 1 ), &kv31[1] );
	DcsPktWrite( kv32[0], ( sizeof( kv32 ) - 1 ), &kv32[1] );
	DcsPktWrite( kv33[0], ( sizeof( kv33 ) - 1 ), &kv33[1] );
	DcsPktWrite( kv34[0], ( sizeof( kv34 ) - 1 ), &kv34[1] );
	DcsPktWrite( kv35[0], ( sizeof( kv35 ) - 1 ), &kv35[1] );
	DcsPktWrite( kv36[0], ( sizeof( kv36 ) - 1 ), &kv36[1] );
	DcsPktWrite( kv37[0], ( sizeof( kv37 ) - 1 ), &kv37[1] );
	DcsPktWrite( kv38[0], ( sizeof( kv38 ) - 1 ), &kv38[1] );
	DcsPktWrite( kv39[0], ( sizeof( kv39 ) - 1 ), &kv39[1] );
	DcsPktWrite( kv40[0], ( sizeof( kv40 ) - 1 ), &kv40[1] );
	DcsPktWrite( kv41[0], ( sizeof( kv41 ) - 1 ), &kv41[1] );
	DcsPktWrite( kv42[0], ( sizeof( kv42 ) - 1 ), &kv42[1] );
	DcsPktWrite( kv43[0], ( sizeof( kv43 ) - 1 ), &kv43[1] );
	DcsPktWrite( kv44[0], ( sizeof( kv44 ) - 1 ), &kv44[1] );
	DcsPktWrite( kv45[0], ( sizeof( kv45 ) - 1 ), &kv45[1] );
	DcsPktWrite( kv46[0], ( sizeof( kv46 ) - 1 ), &kv46[1] );
	DcsPktWrite( kv47[0], ( sizeof( kv47 ) - 1 ), &kv47[1] );
	DcsPktWrite( kv48[0], ( sizeof( kv48 ) - 1 ), &kv48[1] );
	DcsPktWrite( kv49[0], ( sizeof( kv49 ) - 1 ), &kv49[1] );
	DcsPktWrite( kv50[0], ( sizeof( kv50 ) - 1 ), &kv50[1] );
	DcsPktWrite( kv51[0], ( sizeof( kv51 ) - 1 ), &kv51[1] );
	DcsPktWrite( kv52[0], ( sizeof( kv52 ) - 1 ), &kv52[1] );
	DcsPktWrite( kv53[0], ( sizeof( kv53 ) - 1 ), &kv53[1] );
	DcsPktWrite( kv54[0], ( sizeof( kv54 ) - 1 ), &kv54[1] );
	DcsPktWrite( kv55[0], ( sizeof( kv55 ) - 1 ), &kv55[1] );
	DcsPktWrite( kv56[0], ( sizeof( kv56 ) - 1 ), &kv56[1] );
	DcsPktWrite( kv57[0], ( sizeof( kv57 ) - 1 ), &kv57[1] );
	DcsPktWrite( kv58[0], ( sizeof( kv58 ) - 1 ), &kv58[1] );
	DcsPktWrite( kv59[0], ( sizeof( kv59 ) - 1 ), &kv59[1] );
	DcsPktWrite( kv60[0], ( sizeof( kv60 ) - 1 ), &kv60[1] );
	DcsPktWrite( kv61[0], ( sizeof( kv61 ) - 1 ), &kv61[1] );
	DcsPktWrite( kv62[0], ( sizeof( kv62 ) - 1 ), &kv62[1] );
	DcsPktWrite( kv63[0], ( sizeof( kv63 ) - 1 ), &kv63[1] );
	DcsPktWrite( kv64[0], ( sizeof( kv64 ) - 1 ), &kv64[1] );
	DcsPktWrite( kv65[0], ( sizeof( kv65 ) - 1 ), &kv65[1] );
	DcsPktWrite( kv66[0], ( sizeof( kv66 ) - 1 ), &kv66[1] );
	DcsPktWrite( kv67[0], ( sizeof( kv67 ) - 1 ), &kv67[1] );
	DcsPktWrite( kv68[0], ( sizeof( kv68 ) - 1 ), &kv68[1] );
	DcsPktWrite( kv69[0], ( sizeof( kv69 ) - 1 ), &kv69[1] );
	DcsPktWrite( kv70[0], ( sizeof( kv70 ) - 1 ), &kv70[1] );
	DcsPktWrite( kv71[0], ( sizeof( kv71 ) - 1 ), &kv71[1] );
	DcsPktWrite( kv72[0], ( sizeof( kv72 ) - 1 ), &kv72[1] );
	DcsPktWrite( kv73[0], ( sizeof( kv73 ) - 1 ), &kv73[1] );
	DcsPktWrite( kv74[0], ( sizeof( kv74 ) - 1 ), &kv74[1] );
	DcsPktWrite( kv75[0], ( sizeof( kv75 ) - 1 ), &kv75[1] );
	DcsPktWrite( kv76[0], ( sizeof( kv76 ) - 1 ), &kv76[1] );
	DcsPktWrite( kv77[0], ( sizeof( kv77 ) - 1 ), &kv77[1] );
	DcsPktWrite( kv78[0], ( sizeof( kv78 ) - 1 ), &kv78[1] );
	DcsPktWrite( kv79[0], ( sizeof( kv79 ) - 1 ), &kv79[1] );
	DcsPktWrite( kv80[0], ( sizeof( kv80 ) - 1 ), &kv80[1] );
	DcsPktWrite( kv81[0], ( sizeof( kv81 ) - 1 ), &kv81[1] );
	DcsPktWrite( kv82[0], ( sizeof( kv82 ) - 1 ), &kv82[1] );
	DcsPktWrite( kv83[0], ( sizeof( kv83 ) - 1 ), &kv83[1] );
	DcsPktWrite( kv84[0], ( sizeof( kv84 ) - 1 ), &kv84[1] );
	DcsPktWrite( kv85[0], ( sizeof( kv85 ) - 1 ), &kv85[1] );
	DcsPktWrite( kv86[0], ( sizeof( kv86 ) - 1 ), &kv86[1] );
	DcsPktWrite( kv87[0], ( sizeof( kv87 ) - 1 ), &kv87[1] );
	DcsPktWrite( kv88[0], ( sizeof( kv88 ) - 1 ), &kv88[1] );
	DcsPktWrite( kv89[0], ( sizeof( kv89 ) - 1 ), &kv89[1] );
	DcsPktWrite( kv90[0], ( sizeof( kv90 ) - 1 ), &kv90[1] );
	DcsPktWrite( kv91[0], ( sizeof( kv91 ) - 1 ), &kv91[1] );
	DcsPktWrite( kv92[0], ( sizeof( kv92 ) - 1 ), &kv92[1] );
	DcsPktWrite( kv93[0], ( sizeof( kv93 ) - 1 ), &kv93[1] );
	DcsPktWrite( kv94[0], ( sizeof( kv94 ) - 1 ), &kv94[1] );
	DcsPktWrite( kv95[0], ( sizeof( kv95 ) - 1 ), &kv95[1] );
	DcsPktWrite( kv96[0], ( sizeof( kv96 ) - 1 ), &kv96[1] );
	DcsPktWrite( kv97[0], ( sizeof( kv97 ) - 1 ), &kv97[1] );
	DcsPktWrite( kv98[0], ( sizeof( kv98 ) - 1 ), &kv98[1] );
	DcsPktWrite( kv99[0], ( sizeof( kv99 ) - 1 ), &kv99[1] );
	DcsPktWrite( kv100[0], ( sizeof( kv100 ) - 1 ), &kv100[1] );
	DcsPktWrite( kv101[0], ( sizeof( kv101 ) - 1 ), &kv101[1] );
	DcsPktWrite( kv102[0], ( sizeof( kv102 ) - 1 ), &kv102[1] );
	DcsPktWrite( kv103[0], ( sizeof( kv103 ) - 1 ), &kv103[1] );
	DcsPktWrite( kv104[0], ( sizeof( kv104 ) - 1 ), &kv104[1] );
	DcsPktWrite( kv105[0], ( sizeof( kv105 ) - 1 ), &kv105[1] );
	DcsPktWrite( kv106[0], ( sizeof( kv106 ) - 1 ), &kv106[1] );
	DcsPktWrite( kv107[0], ( sizeof( kv107 ) - 1 ), &kv107[1] );
	DcsPktWrite( kv108[0], ( sizeof( kv108 ) - 1 ), &kv108[1] );
	DcsPktWrite( kv109[0], ( sizeof( kv109 ) - 1 ), &kv109[1] );
	DcsPktWrite( kv110[0], ( sizeof( kv110 ) - 1 ), &kv110[1] );
	DcsPktWrite( kv111[0], ( sizeof( kv111 ) - 1 ), &kv111[1] );
	DcsPktWrite( kv112[0], ( sizeof( kv112 ) - 1 ), &kv112[1] );
	DcsPktWrite( kv113[0], ( sizeof( kv113 ) - 1 ), &kv113[1] );
	DcsPktWrite( kv114[0], ( sizeof( kv114 ) - 1 ), &kv114[1] );
	DcsPktWrite( kv115[0], ( sizeof( kv115 ) - 1 ), &kv115[1] );
	DcsPktWrite( kv116[0], ( sizeof( kv116 ) - 1 ), &kv116[1] );
	DcsPktWrite( kv117[0], ( sizeof( kv117 ) - 1 ), &kv117[1] );
	DcsPktWrite( kv118[0], ( sizeof( kv118 ) - 1 ), &kv118[1] );
	DcsPktWrite( kv119[0], ( sizeof( kv119 ) - 1 ), &kv119[1] );
	DcsPktWrite( kv120[0], ( sizeof( kv120 ) - 1 ), &kv120[1] );
	DcsPktWrite( kv121[0], ( sizeof( kv121 ) - 1 ), &kv121[1] );
	DcsPktWrite( kv122[0], ( sizeof( kv122 ) - 1 ), &kv122[1] );
	DcsPktWrite( kv123[0], ( sizeof( kv123 ) - 1 ), &kv123[1] );
	DcsPktWrite( kv124[0], ( sizeof( kv124 ) - 1 ), &kv124[1] );
	DcsPktWrite( kv125[0], ( sizeof( kv125 ) - 1 ), &kv125[1] );
	DcsPktWrite( kv126[0], ( sizeof( kv126 ) - 1 ), &kv126[1] );
	DcsPktWrite( kv127[0], ( sizeof( kv127 ) - 1 ), &kv127[1] );
	DcsPktWrite( kv128[0], ( sizeof( kv128 ) - 1 ), &kv128[1] );
	DcsPktWrite( kv129[0], ( sizeof( kv129 ) - 1 ), &kv129[1] );
	DcsPktWrite( kv130[0], ( sizeof( kv130 ) - 1 ), &kv130[1] );
	DcsPktWrite( kv131[0], ( sizeof( kv131 ) - 1 ), &kv131[1] );
	DcsPktWrite( kv132[0], ( sizeof( kv132 ) - 1 ), &kv132[1] );
	DcsPktWrite( kv133[0], ( sizeof( kv133 ) - 1 ), &kv133[1] );
	DcsPktWrite( kv134[0], ( sizeof( kv134 ) - 1 ), &kv134[1] );
	DcsPktWrite( kv135[0], ( sizeof( kv135 ) - 1 ), &kv135[1] );
	DcsPktWrite( kv136[0], ( sizeof( kv136 ) - 1 ), &kv136[1] );
	DcsPktWrite( kv137[0], ( sizeof( kv137 ) - 1 ), &kv137[1] );
	DcsPktWrite( kv138[0], ( sizeof( kv138 ) - 1 ), &kv138[1] );
	DcsPktWrite( kv139[0], ( sizeof( kv139 ) - 1 ), &kv139[1] );
	DcsPktWrite( kv140[0], ( sizeof( kv140 ) - 1 ), &kv140[1] );
	DcsPktWrite( kv141[0], ( sizeof( kv141 ) - 1 ), &kv141[1] );
	DcsPktWrite( kv142[0], ( sizeof( kv142 ) - 1 ), &kv142[1] );
	DcsPktWrite( kv143[0], ( sizeof( kv143 ) - 1 ), &kv143[1] );
	DcsPktWrite( kv144[0], ( sizeof( kv144 ) - 1 ), &kv144[1] );
	DcsPktWrite( kv145[0], ( sizeof( kv145 ) - 1 ), &kv145[1] );
	DcsPktWrite( kv146[0], ( sizeof( kv146 ) - 1 ), &kv146[1] );
	DcsPktWrite( kv147[0], ( sizeof( kv147 ) - 1 ), &kv147[1] );
	DcsPktWrite( kv148[0], ( sizeof( kv148 ) - 1 ), &kv148[1] );
	DcsPktWrite( kv149[0], ( sizeof( kv149 ) - 1 ), &kv149[1] );
	DcsPktWrite( kv150[0], ( sizeof( kv150 ) - 1 ), &kv150[1] );
	DcsPktWrite( kv151[0], ( sizeof( kv151 ) - 1 ), &kv151[1] );
	DcsPktWrite( kv152[0], ( sizeof( kv152 ) - 1 ), &kv152[1] );
	DcsPktWrite( kv153[0], ( sizeof( kv153 ) - 1 ), &kv153[1] );
	DcsPktWrite( kv154[0], ( sizeof( kv154 ) - 1 ), &kv154[1] );
	DcsPktWrite( kv155[0], ( sizeof( kv155 ) - 1 ), &kv155[1] );
	DcsPktWrite( kv156[0], ( sizeof( kv156 ) - 1 ), &kv156[1] );
	DcsPktWrite( kv157[0], ( sizeof( kv157 ) - 1 ), &kv157[1] );
	DcsPktWrite( kv158[0], ( sizeof( kv158 ) - 1 ), &kv158[1] );
	DcsPktWrite( kv159[0], ( sizeof( kv159 ) - 1 ), &kv159[1] );
	DcsPktWrite( kv160[0], ( sizeof( kv160 ) - 1 ), &kv160[1] );
	DcsPktWrite( kv161[0], ( sizeof( kv161 ) - 1 ), &kv161[1] );
	DcsPktWrite( kv162[0], ( sizeof( kv162 ) - 1 ), &kv162[1] );
	DcsPktWrite( kv163[0], ( sizeof( kv163 ) - 1 ), &kv163[1] );
	DcsPktWrite( kv164[0], ( sizeof( kv164 ) - 1 ), &kv164[1] );
	DcsPktWrite( kv165[0], ( sizeof( kv165 ) - 1 ), &kv165[1] );
	DcsPktWrite( kv166[0], ( sizeof( kv166 ) - 1 ), &kv166[1] );
	DcsPktWrite( kv167[0], ( sizeof( kv167 ) - 1 ), &kv167[1] );
	DcsPktWrite( kv168[0], ( sizeof( kv168 ) - 1 ), &kv168[1] );
	DcsPktWrite( kv169[0], ( sizeof( kv169 ) - 1 ), &kv169[1] );
	DcsPktWrite( kv170[0], ( sizeof( kv170 ) - 1 ), &kv170[1] );
	DcsPktWrite( kv171[0], ( sizeof( kv171 ) - 1 ), &kv171[1] );
	DcsPktWrite( kv172[0], ( sizeof( kv172 ) - 1 ), &kv172[1] );
	DcsPktWrite( kv173[0], ( sizeof( kv173 ) - 1 ), &kv173[1] );
	DcsPktWrite( kv174[0], ( sizeof( kv174 ) - 1 ), &kv174[1] );
	DcsPktWrite( kv175[0], ( sizeof( kv175 ) - 1 ), &kv175[1] );
	DcsPktWrite( kv176[0], ( sizeof( kv176 ) - 1 ), &kv176[1] );
	DcsPktWrite( kv177[0], ( sizeof( kv177 ) - 1 ), &kv177[1] );
	DcsPktWrite( kv178[0], ( sizeof( kv178 ) - 1 ), &kv178[1] );
	DcsPktWrite( kv179[0], ( sizeof( kv179 ) - 1 ), &kv179[1] );
	DcsPktWrite( kv180[0], ( sizeof( kv180 ) - 1 ), &kv180[1] );
	DcsPktWrite( kv181[0], ( sizeof( kv181 ) - 1 ), &kv181[1] );
	DcsPktWrite( kv182[0], ( sizeof( kv182 ) - 1 ), &kv182[1] );
	DcsPktWrite( kv183[0], ( sizeof( kv183 ) - 1 ), &kv183[1] );
	DcsPktWrite( kv184[0], ( sizeof( kv184 ) - 1 ), &kv184[1] );
	DcsPktWrite( kv185[0], ( sizeof( kv185 ) - 1 ), &kv185[1] );
	DcsPktWrite( kv186[0], ( sizeof( kv186 ) - 1 ), &kv186[1] );
	DcsPktWrite( kv187[0], ( sizeof( kv187 ) - 1 ), &kv187[1] );
	DcsPktWrite( kv188[0], ( sizeof( kv188 ) - 1 ), &kv188[1] );
	DcsPktWrite( kv189[0], ( sizeof( kv189 ) - 1 ), &kv189[1] );
	DcsPktWrite( kv190[0], ( sizeof( kv190 ) - 1 ), &kv190[1] );
	DcsPktWrite( kv191[0], ( sizeof( kv191 ) - 1 ), &kv191[1] );
	DcsPktWrite( kv192[0], ( sizeof( kv192 ) - 1 ), &kv192[1] );
	DcsPktWrite( kv193[0], ( sizeof( kv193 ) - 1 ), &kv193[1] );
	HAL_Delay(300);
	DcsPktWrite( kv194[0], ( sizeof( kv194 ) - 1 ), &kv194[1] );
	DcsPktWrite( kv195[0], ( sizeof( kv195 ) - 1 ), &kv195[1] );
	DcsPktWrite( kv196[0], ( sizeof( kv196 ) - 1 ), &kv196[1] );





} 

